package cn.edu.stu.syllabus.library.list;

import cn.edu.stu.syllabus.api.LibraryApi;
import cn.edu.stu.syllabus.repository.library.LibraryDataSource;
import cn.edu.stu.syllabus.repository.library.LibrarySearchInfo;
import cn.edu.stu.syllabus.repository.library.remote.LibraryRemoteDataSource;
import cn.edu.stu.syllabus.di.qualifier.Remote;
import cn.edu.stu.syllabus.di.scope.FragmentScoped;
import cn.edu.stu.syllabus.utils.LibraryRetrofit;
import dagger.Module;
import dagger.Provides;

/**
 * Created by daidaijie on 2017/3/27.
 */

@Module
public class QueryBooksListPresenterModule {

    private final QueryBooksListContract.View mView;

    private final LibrarySearchInfo mLibrarySearchInfo;

    public QueryBooksListPresenterModule(QueryBooksListContract.View view,
                                         LibrarySearchInfo librarySearchInfo) {
        mView = view;
        mLibrarySearchInfo = librarySearchInfo;
    }

    @FragmentScoped
    @Provides
    QueryBooksListContract.View provideView() {
        return mView;
    }

    @FragmentScoped
    @Provides
    LibrarySearchInfo provideLibrarySearchInfo() {
        return mLibrarySearchInfo;
    }

    @FragmentScoped
    @Provides
    LibraryApi provideLibraryApi() {
        return LibraryRetrofit.getRetrofit().create(LibraryApi.class);
    }

    @FragmentScoped
    @Remote
    @Provides
    LibraryDataSource provideRemoteDataSource(LibraryApi libraryApi) {
        return new LibraryRemoteDataSource(libraryApi);
    }


}
